package xyz.wongs.gry.synx.thread

import java.util.concurrent.TimeUnit

/**
 * @ClassName ResultCode 定义的接口状态码
 * @Description
 * @author WCNGS@QQ.COM
 * @Github <a> https://github.com/rothschil</a>
 * @date 2020/12/23 11:31
 * @Version 1.0.0
 */

def ticks = 20
def sale ={->
    synchronized (this){
        TimeUnit.SECONDS.sleep(2)
        println("【多线程】 线程同步 "+Thread.currentThread().getName()+" 】 ，当前剩余票数 "+ ticks--)
    }

}

for (i in 1..<10) {
    def start = Thread.start(sale)
    start.name='Saler - '+i
}